package com.quectel.mobile.controller.forum;

import com.quectel.core.module.forum.dto.mongo.ForumPersonCountDto;
import com.quectel.core.module.forum.service.mongo.ForumPersonCountService;
import com.quectel.mobile.controller.BaseController;
import com.quectel.mobile.util.SessionHolder;
import com.quectel.util.common.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/5/15 9:24
 * @description new java file header...
 */
@RestController
@RequestMapping("forumPersonCount")
@Tag(name = "ForumPersonCountController", description = "发帖数量统计相关api")
public class ForumPersonCountController extends BaseController {


    @DubboReference
    private ForumPersonCountService forumPersonCountService;


    /**
     * 通过Id查询详情
     */
    @GetMapping("info")
    @Operation(summary = "查询统计详情")
    public Response<ForumPersonCountDto> info() {

        if (SessionHolder.getLoginMobileUserSession() == null) {
            return Response.<ForumPersonCountDto>ok().wrap(null);
        }
        ForumPersonCountDto forumPersonCountDto = forumPersonCountService.selectByTenantAndUser(
                SessionHolder.getLoginMobileUserSession().getTenantId(),
                SessionHolder.getLoginMobileUserSession().getMobileUser().getId()
        );

        return Response.<ForumPersonCountDto>ok().wrap(forumPersonCountDto);
    }


}
